import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:testlzhu/view/item_rent.dart';

import 'rent_page_logic.dart';

/// 出租
class RentPagePage extends GetView<RentPagePage> {
  RentPagePage({Key? key}) : super(key: key);
  final RefreshController _refreshController = RefreshController(initialRefresh: false);




  void _onRefresh() {
    var find = Get.find<RentPageLogic>();
    find.getData(state: 1);
  }

  void _onLoading() {
    var find = Get.find<RentPageLogic>();
    find.getData(state: 2);
  }

  @override
  Widget build(BuildContext context) {
    final logic = Get.put(RentPageLogic(_refreshController));
    return GetBuilder<RentPageLogic>(builder: (logic) {
      return SmartRefresher(
        enablePullUp: true,
        enablePullDown: true,
        header: const WaterDropHeader(),
        controller: _refreshController,
        footer: const ClassicFooter(),
        onRefresh: _onRefresh,
        onLoading: _onLoading,
        child: ListView.separated(
          itemCount: logic.datas.length,
          itemBuilder: (context, index) {
            return RentItem(data: logic.datas[index]);

            // return ListTile(
            //   title: Text(logic.datas[index].address!),
            // );
          },
          separatorBuilder: (BuildContext context, int index) {
            return const Divider();
          },
        ),
      );
    });
  }
}
